<?php


namespace app\api\validate;


use think\Validate;

class User extends Validate
{
    protected $rule = [
        'username' => 'require',
        'phone_number' => ['require', 'regex' => '^1([358][0-9]|4[579]|66|7[0135678]|9[89])[0-9]{8}$'],
        'code' => 'require|number|min:4',
        'type' => ['require', 'in' => '1,2'],
        'sex' => 'require|integer'

    ];


    protected $message = [
        'username' => '用户名必须',
        'phone_number.require' => '电话号码必须',
        'phone_number.regex' => '请输入正确的手机号'
    ];

    protected $scene = [
        'send_code' => [
            'phone_number',
        ],
        'login' => [
            'phone_number',
            'code',
            'type'
        ],
        'update' => [
            'username',
            'sex',
        ],
    ];

}